package com.efesco.crm.foreignEnterprise;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.data.db.SqlDataset;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;
import com.efesco.common.DBTools;

/**
 * foreignEnterprise_addViewModel
 */
public class foreignEnterprise_addViewModel extends DefaultViewModel {
  protected void doUpdateData(ParameterSet parameters)
      throws Exception {
    // Add your code here
  	Dataset foreignEnterpriseDataset = getDataset("foreignEnterprise");
  	String newId=DBTools.getNewId("general");
  	foreignEnterpriseDataset.moveFirst();
  	foreignEnterpriseDataset.setValue("foreign_enterprise_id",newId);
  	
   	String sql="insert into s_dept_frn (dept_id,dept_name,deleted,input_man,input_date,foreign_enterprise_id) " +
	"values (general.nextval,'"+foreignEnterpriseDataset.getString("FOREIGN_ENTERPRISE_NAME")+"',0," +
	foreignEnterpriseDataset.getString("INPUT_MAN")+",sysdate,"+newId+")";
   	
  	super.doUpdateData(parameters);    
    
    DBStatement statement = new DBStatement();
    statement.setSql(sql);
    statement.execute();
    statement.close();
  }

}
